#include <stdio.h>
#include <pthread.h>
#include <unistd.h>
void* thread( void *arg )
{

    printf( "This is a thread and arg = %d.\n", *(int*)arg);
    sleep(10);
   // *(int*)arg = 0;
    
}
int main( int argc, char *argv[] )
{
    pthread_t th[2];
    int ret;
    int arg = 10;
    int *thread_ret = NULL;
    ret = pthread_create( &th[0], NULL, thread, &arg );
    ret = pthread_create( &th[1], NULL, thread, &arg );
    if( ret != 0 ){
        printf( "Create thread error!\n");
        return -1;
    }
    printf( "This is the main process.\n" );
    pthread_join( th[1], (void**)&thread_ret );//阻塞主进程
    pthread_join( th[0], (void**)&thread_ret );
    //printf( "thread_ret = %d.\n", *thread_ret );
    return 0;
}